package protocols

import "gitee.com/sjy/selfSendfile/common"

var (
	sendFileObj = make(map[string]SendFile)
)

type SendFile interface {
	Send(file *common.FileInfo, conf *common.Config)
}

func register(name string) SendFile {
	switch name {
	case "tcp":
		return &Send_TCP{}
	case "ftp":
		return &Send_FTP{}
	default:
		return nil
	}
}

func NewSendFile(name string) SendFile {
	if sendFileObj[name] == nil {
		sendFileObj[name] = register(name)
	}
	return sendFileObj[name]
}
